<script setup>
import { inject, ref } from "vue";
import stepsview from "../components/steps/steps.vue";
import { useCounterStore } from "@/stores/upgrade";
import { useUserStore } from "../../stores/user";
import { uploadfile } from "@/services/upload";
import { base_URL } from "@/utils/http";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { areaListApi } from "@/services/address";
import {
  upgradecreate,
  agencyCreate,
  getAreaPrice,
  dataInfo,
  upgradedetails,
  upgradeallnew,
} from "@/services/upfrade";

import { selectbankList } from "@/services/reward";

import { userinfo } from "@/services/user";
const isphone = ref(false);
const isname = ref(false);
const isidcard = ref(false);

const userobj = ref({});
async function userinfofun() {
  let res = await userinfo();
  userobj.value = res.data;
  if (userobj.value.phone) {
    isphone.value = true;
  }
  if (userobj.value.name) {
    isname.value = true;
  }
  if (userobj.value.idcard) {
    isidcard.value = true;
  }
  fromdate.value.phone = userobj.value.phone;
  fromdate.value.name = userobj.value.name;
  fromdate.value.card_no = userobj.value.idcard;
}

const isptpay = ref(false);

// const form = useCounterStore ();
const testid = ref("");
const dateobj = useCounterStore();
const fileList1 = ref([]);
const fileList2 = ref([]);
const fileList3 = ref([]);
const fileList4 = ref([]);
const uForm = ref(null);
const isupgradecard = ref(false);
const fromdate = ref({
  name: "",
  phone: "",
  card_no: "",
});
const carderid = ref("");

const user = useUserStore();

// if (!user.userInfo.phone) {
//   uni.redirectTo({ url: "/pages/upgrade/identitylv" });
// } else {
//   fromdate.value.phone = user.userInfo.phone;
// }
const props = defineProps({
  type: {
    type: String,
    default: () => {
      return "";
    },
  },
});
const type = ref(0);
onLoad((e) => {
  if (e.id) {
    type.value = 1;
    // upgradecreatefun(e.id);
  } else {
    type.value = 2;
  }
  if (e.type) {
    if (e.upgrade_id) {
      isupgradecard.value = true;
      upgradedetailsfun(1, e.upgrade_id);
      type.value = 1;
    }
    if (e.agree_id) {
      isupgradecard.value = true;
      upgradedetailsfun(2, e.agree_id);
      type.value = 2;
    }
    //     if(e.id){

    // upgradedetailsfun(1, e.upgrade_id);
    //     }

    // isupgradecard.value = true;
    fromdate.value.type = type.value;
    userinfofun();

    return;
  }

  if (e.add) {
    isptpay.value = true;
  }
  userinfofun();
  upgradeallnewfun();
  carderid.value = e.id ? e.id : "";
  fromdate.value.level_id = e.id;
  fromdate.value.product_id = e.product_id ? e.product_id : "";
  fromdate.value.type = type.value;
  testid.value = e.id;

  // if (type.value == 1) {
  //   upgradecreatefun(e.id);
  // }
});

async function upgradeallnewfun() {
  let res = await upgradeallnew();
  // debugger;
  if (type.value == 2 && res.data.agree_id) {
    upgradedetailsfun(2, res.data.agree_id);

    // uni.navigateTo({
    //   url:'/pages/upgrade/identityform?type=1&agree_id='+res.data.agree_id
    // })
    return;
  }
  if (type.value == 1 && res.data.upgrade_id && res.data.upgrade_id.id) {
    upgradedetailsfun(1, res.data.upgrade_id.id);
    // uni.navigateTo({
    //   url:'/pages/upgrade/identityform?type=1&upgrade_id='+res.data.upgrade_id
    // })
  }
}

async function upgradedetailsfun(type, id) {
  if (!isupgradecard.value) {
    return;
  }
  let res = await upgradedetails({ type: type, id: id });
  if (type == 2) {
    fromdate.value.dltext = "区";
    fromdate.value.addresstext = res.data.region_text;
  }
  fromdate.value.id = res.data.id;
  if (type == 1) {
    fromdate.value.level_id = res.data.level_id;
    testid.value = res.data.level_id;
  }

  fromdate.value.pay_status = res.data.pay_status;
}

selectbankListfun();
async function selectbankListfun() {
  let res = await selectbankList({
    type: 1,
  });
  array.value = res.data;
}

async function upgradecreatefun(id) {
  try {
    let res = await upgradecreate({
      level_id: id,
    });
    if (res.code == 200) {
      fromdate.value.id = res.data.id;
    }
  } catch (e) {
    uni.$u.toast(e.info);
    // setTimeout(() => {
    //   uni.navigateBack();
    // }, 1000);
  }
}

// 地区
const addresshow = ref(false);
const columns = ref([]);
const dltext = ref("");
const selecttow = ref("");

const addresshowthree = ref(false);
const showtwo = ref(false);
const columnstwo = ref([["省代", "市代", "区代"]]);
const columnsthree = ref([]);
const province = ref([]);
const city = ref([]);
const county = ref([]);
const addressdata = ref([]);
const addresstext = ref("");
areaListFun();

// 获取地区数据
async function areaListFun() {
  //发送请求
  let res = await areaListApi();
  columns.value = [];
  addressdata.value = res.data;
  province.value = res.data;
  city.value = res.data[0].sub;
  county.value = res.data[0].sub[0].sub;
  columns.value.push(province.value, city.value, county.value);
}
const confirmdl = (e) => {
  selecttow.value = e.indexs[0];
  fromdate.value.selecttow = e.indexs[0];

  fromdate.value.dltext = e.value[0];
  fromdate.value.operating_area = {};
  columnsthree.value = [];
  if (selecttow.value == 0) {
    columnsthree.value.push(province.value);
  }
  if (selecttow.value == 1) {
    columnsthree.value.push(province.value, city.value);
  }
  if (selecttow.value == 2) {
    columnsthree.value.push(province.value, city.value, county.value);
  }
  showtwo.value = false;
};
const showaddressfun = () => {
  if (columns.value.length <= 0) {
    areaListFun();
  }

  addresshow.value = true;
};
const selectqdfun = () => {
  fromdate.value.addresstext = "";
  if (addressdata.value.length <= 0) {
    areaListFun();
  }

  showtwo.value = true;
};
const selectselectthreefun = () => {
  columnsthree.value = [];

  if (selecttow.value == 0) {
    columnsthree.value.push(province.value);
  }
  if (selecttow.value == 1) {
    columnsthree.value.push(province.value, city.value);
  }
  if (selecttow.value == 2) {
    columnsthree.value.push(province.value, city.value, county.value);
  }

  addresshowthree.value = true;
};

const confirmaddress = (e) => {
  fromdate.value.operating_area = {
    province: e.value[0].name,
    city: e.value[1].name,
    area: e.value[2].name,
    province_code: e.value[0].code,
    city_code: e.value[1].code,
    area_code: e.value[2].code,
  };
  // fromdate.value

  addresshow.value = false;
};
const confirmaddressthree = async (e) => {
  let code = "";
  if (selecttow.value == 0) {
    code = e.value[0].code;
    fromdate.value.addresstext = e.value[0].name;
  }
  if (selecttow.value == 1) {
    if (!e.value[1]) {
      code = columnsthree.value[1][0].code;
    } else {
      code = e.value[1].code;
    }
    if (!e.value[1]) {
      fromdate.value.addresstext =
        e.value[0].name + "/" + columnsthree.value[1][0].name;
    } else {
      fromdate.value.addresstext = e.value[0].name + "/" + e.value[1].name;
    }
  }
  if (selecttow.value == 2) {
    let name1 = "";
    let name2 = "";
    if (!e.value[1]) {
      name1 = columnsthree.value[1][0].name;
    } else {
      name1 = e.value[1].name;
    }
    if (!e.value[2]) {
      code = columnsthree.value[2][0].code;
      name1 = columnsthree.value[2][0].name;
    } else {
      code = e.value[2].code;
      name2 = e.value[2].name;
    }
    fromdate.value.addresstext = e.value[0].name + "/" + name1 + "/" + name2;
  }

  try {
    let res = await agencyCreate({ code: code });
    if (res.code == 200) {
      fromdate.value.id = res.data.id;
    }
  } catch (e) {
    fromdate.value.addresstext = "";
    uni.$u.toast(e.info);
    // uni.showToast({
    //   title: e.info,
    //   icon: "none",
    // });

    // setTimeout(() => {
    //   uni.navigateBack();
    // }, 1000);
    return;
  }
  try {
    let res = await getAreaPrice({
      region: code,
    });
    if (res.code == 200) {
      fromdate.value.price = res.data.price;
    }
  } catch (e) {
    uni.$u.toast(e.info);
  }

  // fromdate.value

  addresshowthree.value = false;
};
const canceladdress = () => {
  addresshow.value = false;
  addresshowthree.value = false;
  showtwo.value = false;
};
const changeHandler = (e) => {
  const { columnIndex, value, values, index, indexs, code } = e;

  city.value = [];
  county.value = [];
  let lenghts = addressdata.value[indexs[0]].sub.length;
  if (
    addressdata.value &&
    addressdata.value[indexs[0]].sub &&
    !addressdata.value[indexs[0]].sub[indexs[1]]
  ) {
    city.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub;
    county.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub[lenghts - 1] &&
      addressdata.value[indexs[0]].sub[lenghts - 1].sub;
  } else {
    city.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub;
    county.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub[indexs[1]] &&
      addressdata.value[indexs[0]].sub[indexs[1]].sub;
  }
  columns.value = [];
  columns.value.push(province.value, city.value, county.value);
};
const changeHandlerthree = (e) => {
  const { columnIndex, value, values, index, indexs, code } = e;

  city.value = [];
  county.value = [];
  let lenghts = addressdata.value[indexs[0]].sub.length;
  if (
    addressdata.value &&
    addressdata.value[indexs[0]].sub &&
    !addressdata.value[indexs[0]].sub[indexs[1]]
  ) {
    city.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub;
    county.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub[lenghts - 1] &&
      addressdata.value[indexs[0]].sub[lenghts - 1].sub;
  } else {
    city.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub;
    county.value =
      addressdata.value &&
      addressdata.value[indexs[0]] &&
      addressdata.value[indexs[0]].sub[indexs[1]] &&
      addressdata.value[indexs[0]].sub[indexs[1]].sub;
  }
  columnsthree.value = [];
  if (selecttow.value == 0) {
    columnsthree.value.push(province.value);
  }
  if (selecttow.value == 1) {
    columnsthree.value.push(province.value, city.value);
  }
  if (selecttow.value == 2) {
    columnsthree.value.push(province.value, city.value, county.value);
  }
};
const radiovalue1 = ref(1);
fromdate.value.mold = 1;
const current = ref(0);

fromdate.value = { ...fromdate.value, ...dateobj.formdate };
if (dateobj.formdate.type) type.value = dateobj.formdate.type;
fileList1.value = dateobj.formdate.fileList1 ? dateobj.formdate.fileList1 : [];
fileList2.value = dateobj.formdate.fileList2 ? dateobj.formdate.fileList2 : [];
fileList3.value = dateobj.formdate.fileList3 ? dateobj.formdate.fileList3 : [];
fileList4.value = dateobj.formdate.fileList4 ? dateobj.formdate.fileList4 : [];
radiovalue1.value =
  dateobj.formdate && dateobj.formdate.mold ? dateobj.formdate.mold : 1;
selecttow.value =
  dateobj.formdate && dateobj.formdate.selecttow
    ? dateobj.formdate.selecttow
    : 0;

const rules = ref({
  name: {
    type: "string",
    required: true,
    message: "请填写姓名",
    trigger: ["blur", "change"],
  },
  phone: {
    type: "string",
    required: true,
    len: 11,
    message: "请输入11位数手机号",
    trigger: ["blur", "change"],
  },
  business: {
    type: "string",
    required: true,
    message: "请输入公司名称",
    trigger: ["blur", "change"],
  },
  business_card: {
    type: "string",
    required: true,
    message: "请输入营业执照",
    trigger: ["blur", "change"],
  },
  business_code: {
    type: "string",
    required: true,
    trigger: ["blur", "change"],
    message: "请输入统一社会码",
  },
  account: {
    type: "string",
    required: true,
    trigger: ["blur", "change"],
    message: "请输入对公账号",
  },
  bank: {
    type: "string",
    required: true,
    trigger: ["blur", "change"],
    message: "请输入选择开户行",
  },
  bank_open: {
    type: "string",
    required: true,
    trigger: ["blur", "change"],
    message: "请输入支行信息",
  },

  card_no: {
    type: "string",
    required: true,
    len: 18,
    message: "请输入18位数的身份证",
    trigger: ["blur", "change"],
  },
  num: [
    {
      required: true,
      message: "请输入金额",
      trigger: ["change", "blur"],
    },
    {
      // 自定义验证函数，见上说明
      validator: (rule, value, callback) => {
        // 上面有说，返回true表示校验通过，返回false表示不通过
        // uni.$u.test.mobile()就是返回true或者false的
        return uni.$u.test.amount(value);
      },
      message: "请输入正确的金额",
      // 触发器可以同时用blur和change
      trigger: ["change", "blur"],
    },
  ],
});
const btformdata = ref({
  columns: [
    ["中国", "美国"],
    ["深圳", "厦门", "上海", "拉萨"],
  ],
  columnData: [
    ["深圳", "厦门", "上海", "拉萨"],
    ["得州", "华盛顿", "纽约", "阿拉斯加"],
  ],
});
const btformdatashow = ref(false);
const confirm = (e) => {
  btformdatashow.value = false;
};
const cancel = () => {
  btformdatashow.value = false;
};
// 单选
const radiolist1 = ref([
  {
    name: "个人",
    value: 1,
    disabled: false,
  },
  {
    name: "企业",
    value: 2,
    disabled: false,
  },
]);

const radioChange = (value) => {
  fromdate.value.mold = value;
};

const nextfun = () => {
  fromdate.value.fileList1 = fileList1.value;
  fromdate.value.fileList2 = fileList2.value;
  fromdate.value.fileList3 = fileList3.value;
  fromdate.value.fileList4 = fileList4.value;
  dateobj.setformdate({
    ...dateobj.formdate,
    ...fromdate.value,
  });

  if (type.value == 2) {
    if (!fromdate.value.dltext) {
      uni.$u.toast("请选择代理等级");
      return;
    }
    if (!fromdate.value.addresstext) {
      uni.$u.toast("请选择代理区域");
      return;
    }
    if (!fromdate.value.price && !isupgradecard) {
      uni.$u.toast("该区域不能代理,请重新选择");
      return;
    }
  }

  // if (type.value == 1) {
  //   if (fileList1.value.length <= 0) {
  //     uni.$u.toast("请上传身份证正面");
  //     return;
  //   }
  //   if (fileList2.value.length <= 0) {
  //     uni.$u.toast("请上传身份证正面");
  //     return;
  //   }
  //   if (fileList3.value.length <= 0) {
  //     uni.$u.toast("请上传身份证正面");
  //     return;
  //   }
  // }
  // if (type.value == 2 && radiovalue1.value == 1) {
  //   if (fileList1.value.length <= 0) {
  //     uni.$u.toast("请上传身份证正面");
  //     return;
  //   }
  //   if (fileList2.value.length <= 0) {
  //     uni.$u.toast("请上传身份证正面");
  //     return;
  //   }
  //   if (fileList3.value.length <= 0) {
  //     uni.$u.toast("请上传身份证正面");
  //     return;
  //   }
  // }
  if (
    type.value == 2 &&
    radiovalue1.value == 2 &&
    fileList4.value.length <= 0
  ) {
    uni.$u.toast("请上传营业执照");
    return;
  }
  // debugger;
  // if (type.value == 1 && fromdate.value.level_id != "201") {
  //   if (!fromdate.value.operating_area) {
  //     uni.$u.toast("请选择营业区域");
  //     return;
  //   }
  // }
  // if (type.value == 2 && !fromdate.value.operating_area) {
  //   uni.$u.toast("请选择营业区域");
  //   return;
  // }

  uForm.value
    .validate()
    .then(async (valid) => {
      if (valid) {
        // uni.navigateTo({
        //   url:
        //     "/pages/upgrade/upgradepay?type=" +
        //     type.value +
        //     "&product_id=" +
        //     fromdate.value.product_id,
        // });

        fromdate.value.card_z =
          fileList1.value.length > 0 ? fileList1.value[0].url : "";
        fromdate.value.card_f =
          fileList2.value.length > 0 ? fileList2.value[0].url : "";
        fromdate.value.card_s =
          fileList3.value.length > 0 ? fileList3.value[0].url : "";
        fromdate.value.business_card =
          fileList4.value.length > 0 ? fileList4.value[0].url : "";

        try {
          if (type.value == 1) {
            if (carderid.value && !fromdate.value.id) {
              try {
                let ress = await upgradecreate({
                  level_id: carderid.value,
                });
                if (ress.code == 200) {
                  fromdate.value.id = ress.data.id;
                }
              } catch (e) {
                uni.$u.toast(e.info);
                setTimeout(() => {
                  uni.navigateBack();
                }, 1000);
                return;
              }
            }
          }

          let res = await dataInfo(fromdate.value);
          uni.navigateTo({
            url:
              "/pages/upgrade/agreement?type=" +
              type.value +
              "&product_id=" +
              (fromdate.value.product_id ? fromdate.value.product_id : "") +
              "&id=" +
              fromdate.value.id +
              "&level_id=" +
              (fromdate.value.level_id ? fromdate.value.level_id : "") +
              "&pay_status=" +
              (fromdate.value.pay_status ? fromdate.value.pay_status : ""),
          });
        } catch (e) {
          uni.$u.toast(e.info);
        }
      } else {
        uni.$u.toast("请留意以上必填信息");
      }
    })
    .catch((e) => {
      // 处理验证错误
      uni.$u.toast(e[0].message);
    });
};

//上传图片
// 删除图片
const deletePic1 = (event, type) => {
  let fileList = [];

  fileList = fileList1.value;

  fileList.splice(event.index, 1);
};
const afterRead1 = async (event, type) => {
  let fileListLen = 0;
  let filelist = [];
  // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式

  fileListLen = fileList1.value.length;
  filelist = fileList1.value;

  let lists = [].concat(event.file);
  lists.map((item) => {
    filelist.push({
      ...item,
      status: "uploading",
      message: "上传中",
    });
  });

  // return;
  for (let i = 0; i < lists.length; i++) {
    uni.uploadFile({
      url: base_URL + "/api/upload/file",
      filePath: lists[i].url,
      name: "file",
      formData: {
        user: "test",
      },
      header: {
        Authorization: uni.getStorageSync("Authorization"),
      },
      success: async (uploadFileRes) => {
        let data = JSON.parse(uploadFileRes.data);
        if (data.code == 200) {
          filelist.splice(fileListLen, 1, {
            ...item,
            status: "success",
            message: "",
            url: data.data.url,
          });
          fileListLen++;
        }
      },
      fail: function (e) {
        uni.hideLoading();
      },
    });

    let item = fileList1.value[fileListLen];
  }
};
const deletePic2 = (event, type) => {
  let fileList = [];

  fileList = fileList2.value;

  fileList.splice(event.index, 1);
};
const afterRead2 = async (event, type) => {
  let fileListLen = 0;
  let filelist = [];
  // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式

  fileListLen = fileList2.value.length;
  filelist = fileList2.value;

  let lists = [].concat(event.file);
  lists.map((item) => {
    filelist.push({
      ...item,
      status: "uploading",
      message: "上传中",
    });
  });

  // return;
  for (let i = 0; i < lists.length; i++) {
    uni.uploadFile({
      url: base_URL + "/api/upload/file",
      filePath: lists[i].url,
      name: "file",
      formData: {
        user: "test",
      },
      header: {
        Authorization: uni.getStorageSync("Authorization"),
      },
      success: async (uploadFileRes) => {
        let data = JSON.parse(uploadFileRes.data);
        if (data.code == 200) {
          filelist.splice(fileListLen, 1, {
            ...item,
            status: "success",
            message: "",
            url: data.data.url,
          });
          fileListLen++;
        }
      },
      fail: function (e) {
        uni.hideLoading();
      },
    });

    let item = fileList2.value[fileListLen];
  }
};
const deletePic3 = (event, type) => {
  let fileList = [];

  fileList = fileList3.value;

  fileList.splice(event.index, 1);
};
const afterRead3 = async (event, type) => {
  let fileListLen = 0;
  let filelist = [];
  // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式

  fileListLen = fileList3.value.length;
  filelist = fileList3.value;

  let lists = [].concat(event.file);
  lists.map((item) => {
    filelist.push({
      ...item,
      status: "uploading",
      message: "上传中",
    });
  });

  // return;
  for (let i = 0; i < lists.length; i++) {
    uni.uploadFile({
      url: base_URL + "/api/upload/file",
      filePath: lists[i].url,
      name: "file",
      formData: {
        user: "test",
      },
      header: {
        Authorization: uni.getStorageSync("Authorization"),
      },
      success: async (uploadFileRes) => {
        let data = JSON.parse(uploadFileRes.data);
        if (data.code == 200) {
          filelist.splice(fileListLen, 1, {
            ...item,
            status: "success",
            message: "",
            url: data.data.url,
          });
          fileListLen++;
        }
      },
      fail: function (e) {
        uni.hideLoading();
      },
    });

    let item = fileList3.value[fileListLen];
  }
};
const deletePic4 = (event, type) => {
  let fileList = [];

  fileList = fileList4.value;

  fileList.splice(event.index, 1);
};
const afterRead4 = async (event, type) => {
  let fileListLen = 0;
  let filelist = [];
  // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式

  fileListLen = fileList4.value.length;
  filelist = fileList4.value;

  let lists = [].concat(event.file);
  lists.map((item) => {
    filelist.push({
      ...item,
      status: "uploading",
      message: "上传中",
    });
  });

  // return;
  for (let i = 0; i < lists.length; i++) {
    uni.uploadFile({
      url: base_URL + "/api/upload/file",
      filePath: lists[i].url,
      name: "file",
      formData: {
        user: "test",
      },
      header: {
        Authorization: uni.getStorageSync("Authorization"),
      },
      success: async (uploadFileRes) => {
        let data = JSON.parse(uploadFileRes.data);
        if (data.code == 200) {
          filelist.splice(fileListLen, 1, {
            ...item,
            status: "success",
            message: "",
            url: data.data.url,
          });
          fileListLen++;
        }
      },
      fail: function (e) {
        uni.hideLoading();
      },
    });

    let item = fileList4.value[fileListLen];
  }
};

const index = ref(-1);
const array = ref([]);

const bindPickerChange = (e) => {
  index.value = e.detail.value;
  fromdate.value.bank = array.value[index.value].bank_name;
};
</script>

<template>
  <view class="upgrade">
    <stepsview :current="current"></stepsview>
    <view class="upgrade-ts">
      成为{{
        testid == 201
          ? "VIP用户"
          : testid == 301
          ? "联盟店"
          : testid == 401
          ? "认证店"
          : testid == 501
          ? "形象店"
          : testid == 601
          ? "旗航店"
          : "公司"
      }}需与公司签定合同，请填写以下资料：
    </view>
    <view class="foodr-list foodr-list-2" v-if="type == 2 && isupgradecard">
      <view
        class="list-index list-index-left1"
        v-if="type == 2 && fromdate.dltext"
      >
        <view class="list-index-left list-index-left-qy"
          ><text>*</text>区域选择</view
        >
        <view class="list-index-right add-witdh">
          {{ fromdate.addresstext ? fromdate.addresstext : "请选择省/市/区" }}
          <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
        </view>
      </view>
    </view>

    <view class="foodr-list foodr-list-2" v-if="type == 2 && !isupgradecard">
      <view class="list-index list-index-left1">
        <view class="list-index-left list-index-left-qy"
          ><text>*</text>代理等级</view
        >
        <view
          :class="
            fromdate.dltext ? 'list-index-right-select' : 'list-index-right'
          "
          @click="selectqdfun"
        >
          {{ fromdate.dltext ? fromdate.dltext : "代理级别" }}
          <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
        </view>
      </view>
      <view
        class="list-index list-index-left1"
        v-if="type == 2 && fromdate.dltext"
      >
        <view class="list-index-left list-index-left-qy"
          ><text>*</text>区域选择</view
        >
        <view
          :class="
            fromdate.addresstext
              ? 'list-index-right-select add-witdh'
              : 'list-index-right add-witdh'
          "
          @click="selectselectthreefun"
        >
          {{ fromdate.addresstext ? fromdate.addresstext : "请选择省/市/区" }}
          <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
        </view>
      </view>
    </view>

    <u--form
      labelPosition="left"
      :model="fromdate"
      :rules="rules"
      ref="uForm"
      labelWidth="80"
    >
      <view class="user-paynum" v-if="type == 2 && fromdate.price">
        <u-form-item label="认购金额" borderBottom ref="item1">
          <!-- <text class="user-paynum-titles">¥</text> -->
          <!-- <u--input
            v-model="fromdate.num"
            border="none"
            placeholder="请填写"
          ></u--input> -->
        </u-form-item>
        <view class="user-paynum-top"></view>
        <u-form-item labelWidth="0rpx" prop="price" borderBottom ref="item1">
          <text class="user-paynum-titles">¥</text>
          <u--input
            v-model="fromdate.price"
            border="none"
            fontSize="28"
            placeholder="请输入金额"
            :disabled="true"
          ></u--input>
        </u-form-item>
      </view>

      <view class="user-form" v-if="type == 2">
        <u-form-item
          required="true"
          label="经营主体"
          prop="name"
          borderBottom
          ref="item1"
        >
          <u-radio-group
            v-model="radiovalue1"
            placement="column"
            @change="groupChange"
          >
            <u-radio
              :customStyle="{ marginBottom: '8px' }"
              v-for="(item, index) in radiolist1"
              :key="index"
              activeColor="#F3498B "
              :label="item.name"
              :name="item.value"
              @change="radioChange"
            >
            </u-radio>
          </u-radio-group>
        </u-form-item>

        <!-- 个人 -->
        <view v-if="type == 2 && radiovalue1 == 1">
          <u-form-item
            required="true"
            label="姓名"
            prop="name"
            borderBottom
            ref="item1"
          >
            <u--input
              v-model="fromdate.name"
              :disabled="isname ? true : false"
              border="none"
              placeholder="请填写"
            ></u--input>
          </u-form-item>
          <u-form-item
            required="true"
            label="手机号"
            prop="phone"
            borderBottom
            ref="item1"
          >
            <u--input
              :disabled="isphone ? true : false"
              v-model="fromdate.phone"
              border="none"
              placeholder="请填写"
            ></u--input>
          </u-form-item>
          <view class="item-line">
            <u-form-item
              required="true"
              label="身份证号"
              prop="card_no"
              borderBottom
              ref="item1"
            >
              <u--input
                :disabled="isidcard ? true : false"
                v-model="fromdate.card_no"
                border="none"
                placeholder="请填写"
              ></u--input>
            </u-form-item>
          </view>
        </view>

        <!-- 企业 -->
        <view v-if="type == 2 && radiovalue1 == 2">
          <u-form-item
            required="true"
            label="企业名称"
            prop="business"
            borderBottom
            ref="item1"
          >
            <u--input
              v-model="fromdate.business"
              border="none"
              placeholder="请输入企业名称"
            ></u--input>
          </u-form-item>
          <u-form-item
            required="true"
            label="法人"
            prop="name"
            borderBottom
            ref="item1"
          >
            <u--input
              v-model="fromdate.name"
              :disabled="isname ? true : false"
              border="none"
              placeholder="请输入法人"
            ></u--input>
          </u-form-item>
          <u-form-item
            required="true"
            label="手机号"
            prop="phone"
            borderBottom
            ref="item1"
          >
            <u--input
              :disabled="isphone ? true : false"
              v-model="fromdate.phone"
              border="none"
              placeholder="请填写"
            ></u--input>
          </u-form-item>
          <view class="item-line">
            <u-form-item
              required="true"
              label="统一社会码"
              prop="business_code"
              borderBottom
              ref="item1"
            >
              <u--input
                v-model="fromdate.business_code"
                border="none"
                placeholder="请填写"
              ></u--input>
            </u-form-item>
          </view>
        </view>
      </view>

      <!-- 开户行 -->

      <view class="user-form" v-if="type == 2 && radiovalue1 == 2">
        <u-form-item
          required="true"
          label="对公账号"
          prop="account"
          borderBottom
          ref="item1"
        >
          <u--input
            v-model="fromdate.account"
            border="none"
            placeholder="请填写"
          ></u--input>
        </u-form-item>
        <u-form-item
          required="true"
          label="开户银行"
          prop="bank"
          borderBottom
          ref="item1"
        >
          <picker
            @change="bindPickerChange"
            :value="index"
            :range="array"
            range-key="bank_name"
            style="width: 100%;"
          >
            <!-- <view class="uni-input select-uni-input" v-if="index >= 0"
              >{{ array[index].bank_name }}
            </view>
            <view class="uni-input" v-if="index < 0"> 请选择 </view> -->
            <!-- 1111111111 -->
            <view v-if="fromdate.bank">
              <view class="list-index-right"
                >{{ fromdate.bank }}
                <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
              </view>
            </view>
            <view v-else>
              <view class="list-index-right" v-if="index >= 0"
                >{{ array[index].bank_name }}
                <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
              </view>
              <view class="list-index-right" v-if="index < 0"
                >请选择
                <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
              </view>
            </view>
          </picker>
        </u-form-item>
        <view class="item-line">
          <u-form-item
            label="支行信息"
            required="true"
            prop="bank_open"
            borderBottom
            ref="item1"
          >
            <u--input
              v-model="fromdate.bank_open"
              border="none"
              placeholder="请填写支行信息"
            ></u--input>
          </u-form-item>
        </view>
      </view>

      <!-- 店长 -->

      <view class="user-form" v-if="type == 1">
        <u-form-item
          required="true"
          label="姓名"
          prop="name"
          borderBottom
          ref="item1"
        >
          <u--input
            :disabled="isname ? true : false"
            v-model="fromdate.name"
            border="none"
            placeholder="请填写"
          ></u--input>
        </u-form-item>
        <u-form-item
          required="true"
          label="手机号"
          prop="phone"
          borderBottom
          ref="item1"
        >
          <u--input
            :disabled="isphone ? true : false"
            v-model="fromdate.phone"
            border="none"
            placeholder="请填写"
          ></u--input>
        </u-form-item>

        <view class="item-line">
          <u-form-item
            required="true"
            label="身份证号"
            prop="card_no"
            borderBottom
            ref="item1"
          >
            <u--input
              :disabled="isidcard ? true : false"
              v-model="fromdate.card_no"
              border="none"
              placeholder="请填写"
            ></u--input>
          </u-form-item>
        </view>
      </view>
    </u--form>

    <view class="uplade" v-if="type == 1 || (type == 2 && radiovalue1 == 1)">
      <view class="uplade-title"
        ><text>上传身份证照片</text>
        <!-- <image src="@/pages/upgrade/static/icon-1.png" mode="widthFix" />
        <text class="uplade-ts">注意事项</text> -->
      </view>
      <view class="uplade-up">
        <up-upload
          :fileList="fileList1"
          @afterRead="
            (val) => {
              afterRead1(val, 1);
            }
          "
          @delete="
            (val) => {
              deletePic1(val, 1);
            }
          "
          name="1"
          multiple
          :maxCount="1"
          width="250"
          height="150"
        >
          <image
            src="@/pages/upgrade/static/icon-4.png"
            mode="widthFix"
            style="width: 254rpx; height: 180rpx;"
          ></image>
          <view class="upload-list">正面（人像）</view>
        </up-upload>
        <up-upload
          :fileList="fileList2"
          @afterRead="
            (val) => {
              afterRead2(val, 2);
            }
          "
          @delete="
            (val) => {
              deletePic2(val, 2);
            }
          "
          name="2"
          multiple
          :maxCount="1"
          width="250"
          height="150"
        >
          <image
            src="@/pages/upgrade/static/icon-2.png"
            mode="widthFix"
            style="width: 254rpx; height: 180rpx;"
          ></image>
          <view class="upload-list">反面（国徽）</view>
        </up-upload>
      </view>
      <view class="uplade-up">
        <up-upload
          :fileList="fileList3"
          @afterRead="
            (val) => {
              afterRead3(val, 3);
            }
          "
          @delete="
            (val) => {
              deletePic3(val, 3);
            }
          "
          name="3"
          multiple
          :maxCount="1"
          width="250"
          height="150"
        >
          <image
            src="@/pages/upgrade/static/icon-3.png"
            mode="widthFix"
            style="width: 254rpx; height: 180rpx;"
          ></image>
          <view class="upload-list">手持身份证</view>
        </up-upload>
        <view class="zhanw"></view>
      </view>
    </view>

    <view class="uplade" v-if="radiovalue1 == 2">
      <view class="uplade-title"
        ><text>上传营业执照</text>
        <!-- <image src="@/pages/upgrade/static/icon-1.png" mode="widthFix" />
        <text class="uplade-ts">注意事项</text> -->
      </view>

      <view class="uplade-up">
        <up-upload
          :fileList="fileList4"
          @afterRead="
            (val) => {
              afterRead4(val, 4);
            }
          "
          @delete="
            (val) => {
              deletePic4(val, 4);
            }
          "
          name="4"
          multiple
          :maxCount="1"
          width="250"
          height="150"
        >
          <image
            src="@/pages/upgrade/static/icon-3.png"
            mode="widthFix"
            style="width: 254rpx; height: 180rpx;"
          ></image>
          <view class="upload-list">营业执照</view>
        </up-upload>
        <view class="zhanw"></view>
      </view>
    </view>
    <!-- v-if="(type == 1 || type == 2) && fromdate.level_id != 201" -->
    <!-- <view class="foodr-list" v-if="type == 1 && fromdate.level_id != 201">
      <view class="list-index">
        <view class="list-index-left">经营区域</view>
        <view class="list-index-right add-witdh" @click="showaddressfun">
          {{
            fromdate.operating_area && fromdate.operating_area.province
              ? fromdate.operating_area.province +
                "/" +
                fromdate.operating_area.city +
                "/" +
                fromdate.operating_area.area
              : "请选择省/市/区"
          }}

          <u-icon name="arrow-right" color="#8C8C8C" size="16"></u-icon>
        </view>
      </view>
      <view class="list-index">
        <view class="list-index-left">经营地址</view>
        <view class="list-index-input">
          <u--input
            v-model="fromdate.address"
            placeholder="经营地址"
            border="none"
          ></u--input
        ></view>
      </view>
    </view> -->
  </view>

  <view class="foodr-bt">
    <view class="bt-sbuit" @click="nextfun">下一步</view>
  </view>
  <u-picker
    :show="btformdatashow"
    ref="uPicker"
    :columns="btformdata.columns"
    @confirm="confirm"
    @change="changeHandler"
    @cancel="cancel"
  >
  </u-picker>

  <up-picker
    :show="addresshow"
    ref="uPickerRef"
    :columns="columns"
    keyName="name"
    @cancel="canceladdress"
    @confirm="confirmaddress"
    @change="changeHandler"
  ></up-picker>
  <up-picker
    :show="addresshowthree"
    ref="uPickerRef"
    :columns="columnsthree"
    keyName="name"
    @cancel="canceladdress"
    @confirm="confirmaddressthree"
    @change="changeHandlerthree"
  ></up-picker>

  <up-picker
    :show="showtwo"
    :columns="columnstwo"
    @cancel="canceladdress"
    @confirm="confirmdl"
  ></up-picker>
</template>

<style lang="scss" scoped>
@import "./identityform.scss";
</style>
